{ INFORMATICS.MCCME.RU
  Problem statement: http://informatics.mccme.ru/moodle/mod/statements/view3.php?chapterid=360
  Verdict: Accepted
}
uses SysUtils, Math;
 
var
	i,j,n,m:longint;
	a:array[0..1010,0..1010] of longint;
	curP,ansP,ans:int64;
	pp:array[0..1010] of longint;
 
begin
reset(input,'input.txt');
rewrite(output,'output.txt');
fillchar(a,sizeof(a),0);
read(n,m);
for i:=1 to n do
	for j:=1 to m do read(a[i][j]);
ansP:=-1;
ans:=0;
for i:=1 to n do begin
	curP:=0;
	for j:=1 to m do
		curP:=max(curP,a[i][j]);
	if curP>ansP then begin	
		ansP:=curP;
		ans:=1;
		pp[1]:=i-1;
	end else
	if curP=ansP then begin
		inc(ans);
		pp[ans]:=i-1;
	end;
end;
writeln(ans);
for i:=1 to ans do
	write(pp[i],' ');
end.